import { ElMessage } from "element-plus";

export const beupload = (file) => {
  const suffix = file.name.split('.').at(-1) || ''
  if (!['jpg', 'jpeg', 'png'].includes(suffix)) {
    ElMessage.error('请上传 jpg、jpeg、png 格式的图片')
    return false
  }
}

export const successful = (response, file) => {
  console.info('upload.js - successful', response, file)
  if (response.code === 200 && response.data) {
    return response.data
  }
  ElMessage.error('上传失败')
}
